<% include_stylesheet 'admin/extensions/assets/assets' %>

<h1>Edit Asset</h1>

<% form_for [:admin, @asset], :html => {:multipart => true, 'data-onsubmit_status' => onsubmit_status(@asset)} do |f| %>
  <div class="form_area">
    <p class="title">
      Caption: <%= f.text_field :caption %>
    </p>
    <table>
      <tbody>
        <tr><th>Name</th><td><%= @asset.upload.name %></td></tr>
        <% if @asset.image? %>
        <tr><th>Width</th><td><%= @asset.upload.width %></td></tr>
        <tr><th>Height</th><td><%= @asset.upload.height %></td></tr>
        <% end %>
      </tbody>
    </table>
    <%= f.file_field :upload %>
    <%= display(@asset) %>
    <%- if @asset.page_attachments.any? -%>
      <h2>Included on <%= pluralize(@asset.page_attachments.size, 'this page', 'these pages') %>:</h2>
      <ul>
        <%- @asset.page_attachments.each do |attachment| -%>
          <li><%= link_to attachment.parent.title, edit_admin_page_path(attachment.parent) %></li>
        <%- end -%>
      </ul>
    <%- end -%>
  </div>
  <p class="buttons">
    <%= save_model_button(@asset) %>
    <%= save_model_and_continue_editing_button(@asset) %>
    or <%= link_to 'Cancel', admin_assets_url %>
  </p>
<% end %>
